/**
 * EditProjectInfoForm class.
 */
package pits.form;

import java.util.ArrayList;
import java.util.List;

import javax.portlet.ActionRequest;

import pits.util.Errand;

public class EditProjectInfoForm {

	private int projectID;
	private String projectName;
	private String description;
	private int companyID;
	private String department;
	private String periodFrom;
	private String periodTo;
	private String size;
	private List<String> langNames;
	private List<Integer> langIDs;
	private List<String> appNames;
	private List<Integer> appIDs;
	private List<String> techNames;
	private List<Integer> techIDs;
	private List<String> frameNames;
	private List<Integer> frameIDs;

	public EditProjectInfoForm(String txtProjectID) {
		projectID = Integer.parseInt(txtProjectID);
	}

	/**
	 * @return list of errors if exist
	 */
	public List<String> validate() {

		List<String> errorMess = new ArrayList<String>();

		return errorMess;
	}

	/**
	 * @param request
	 */
	public void setFields(ActionRequest request) {

		Errand errand = new Errand();

		if (request.getParameter("projectName") != null) {
			setProjectName(request.getParameter("projectName"));
		}
		if (request.getParameter("description") != null) {
			setDescription(request.getParameter("description"));
		}
		if (request.getParameter("companyID") != null) {
			setCompanyID(Integer.parseInt(request.getParameter("companyID")));
		}
		if (request.getParameter("department") != null) {
			setDepartmentID(request.getParameter("department"));
		}
		if (request.getParameter("periodFrom") != null) {
			setPeriodFrom(errand.parseDate(request.getParameter("periodFrom").toString()));
		}
		if (request.getParameter("periodTo") != null) {
			setPeriodTo(errand.parseDate(request.getParameter("periodTo").toString()));
		}
		if (request.getParameter("size") != null) {
			setSize(request.getParameter("size").toString());
		}

		/**
		 * Language list
		 */
		List<Integer> langIDs = new ArrayList<Integer>();
		List<String> langNames = new ArrayList<String>();

		errand.parseNameID(request.getParameter("language").split(":"), langIDs, langNames);

		setLangIDs(langIDs);
		setLangNames(langNames);

		/**
		 * Application list
		 */
		List<Integer> appIDs = new ArrayList<Integer>();
		List<String> appNames = new ArrayList<String>();

		errand.parseNameID(request.getParameter("application").split(":"), appIDs, appNames);

		setAppIDs(appIDs);
		setAppNames(appNames);

		/**
		 * Technology list
		 */
		List<Integer> techIDs = new ArrayList<Integer>();
		List<String> techNames = new ArrayList<String>();

		errand.parseNameID(request.getParameter("technology").split(":"), techIDs, techNames);

		setTechIDs(techIDs);
		setTechNames(techNames);

		/**
		 * Framework list
		 */
		List<Integer> frameIDs = new ArrayList<Integer>();
		List<String> frameNames = new ArrayList<String>();

		errand.parseNameID(request.getParameter("framework").split(":"), frameIDs, frameNames);

		setFrameIDs(frameIDs);
		setFrameNames(frameNames);
	}

	/**
	 * @return the projectID
	 */
	public int getProjectID() {
		return projectID;
	}

	/**
	 * @param projectID
	 *            the projectID to set
	 */
	public void setProjectID(int projectID) {
		this.projectID = projectID;
	}

	/**
	 * @return the projectName
	 */
	public String getProjectName() {
		return projectName;
	}

	/**
	 * @param projectName
	 *            the projectName to set
	 */
	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the companyID
	 */
	public int getCompanyID() {
		return companyID;
	}

	/**
	 * @param companyID
	 *            the companyID to set
	 */
	public void setCompanyID(int companyID) {
		this.companyID = companyID;
	}

	/**
	 * @return the departmentID
	 */
	public String getDepartment() {
		return department;
	}

	/**
	 * @param departmentID
	 *            the departmentID to set
	 */
	public void setDepartmentID(String department) {
		this.department = department;
	}

	/**
	 * @return the periodFrom
	 */
	public String getPeriodFrom() {
		return periodFrom;
	}

	/**
	 * @param periodFrom
	 *            the periodFrom to set
	 */
	public void setPeriodFrom(String periodFrom) {
		this.periodFrom = periodFrom;
	}

	/**
	 * @return the periodTo
	 */
	public String getPeriodTo() {
		return periodTo;
	}

	/**
	 * @param periodTo
	 *            the periodTo to set
	 */
	public void setPeriodTo(String periodTo) {
		this.periodTo = periodTo;
	}

	/**
	 * @return the size
	 */
	public String getSize() {
		return size;
	}

	/**
	 * @param size
	 *            the size to set
	 */
	public void setSize(String size) {
		this.size = size;
	}

	/**
	 * @return the langNames
	 */
	public List<String> getLangNames() {
		return langNames;
	}

	/**
	 * @param langNames
	 *            the langNames to set
	 */
	public void setLangNames(List<String> langNames) {
		this.langNames = langNames;
	}

	/**
	 * @return the langIDs
	 */
	public List<Integer> getLangIDs() {
		return langIDs;
	}

	/**
	 * @param langIDs
	 *            the langIDs to set
	 */
	public void setLangIDs(List<Integer> langIDs) {
		this.langIDs = langIDs;
	}

	/**
	 * @return the appNames
	 */
	public List<String> getAppNames() {
		return appNames;
	}

	/**
	 * @param appNames
	 *            the appNames to set
	 */
	public void setAppNames(List<String> appNames) {
		this.appNames = appNames;
	}

	/**
	 * @return the appIDs
	 */
	public List<Integer> getAppIDs() {
		return appIDs;
	}

	/**
	 * @param appIDs
	 *            the appIDs to set
	 */
	public void setAppIDs(List<Integer> appIDs) {
		this.appIDs = appIDs;
	}

	/**
	 * @return the techNames
	 */
	public List<String> getTechNames() {
		return techNames;
	}

	/**
	 * @param techNames
	 *            the techNames to set
	 */
	public void setTechNames(List<String> techNames) {
		this.techNames = techNames;
	}

	/**
	 * @return the techIDs
	 */
	public List<Integer> getTechIDs() {
		return techIDs;
	}

	/**
	 * @param techIDs
	 *            the techIDs to set
	 */
	public void setTechIDs(List<Integer> techIDs) {
		this.techIDs = techIDs;
	}

	/**
	 * @return the frameNames
	 */
	public List<String> getFrameNames() {
		return frameNames;
	}

	/**
	 * @param frameNames
	 *            the frameNames to set
	 */
	public void setFrameNames(List<String> frameNames) {
		this.frameNames = frameNames;
	}

	/**
	 * @return the frameIDs
	 */
	public List<Integer> getFrameIDs() {
		return frameIDs;
	}

	/**
	 * @param frameIDs
	 *            the frameIDs to set
	 */
	public void setFrameIDs(List<Integer> frameIDs) {
		this.frameIDs = frameIDs;
	}
}
